﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.BLL;
using COM.OA.Entity;

public partial class lb_upload : System.Web.UI.Page
{
    private HttpPostedFile UploadFile
    {
        get
        {
            return this.Request.Files["file1"];
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //获取登陆的用户信息
        users u = (users)Session["loginuser"];
        if (u == null)
        {
            this.Response.Write(string.Format(GetRedirect.REDIRECT,"../login.aspx"));
        }
        if (this.UploadFile != null)
        {
            
            int startIndex = this.UploadFile.FileName.LastIndexOf(@"\")+1;
            string fileName = this.UploadFile.FileName.Substring(startIndex);
            string phyFileName = this.Server.MapPath(@"..\gxxz\upload\") + fileName;
            this.UploadFile.SaveAs(phyFileName);
            
            //文件实体
            files upFile = new files();
            upFile.f_filename = fileName;
            upFile.f_releasetime = DateTime.Now.ToLocalTime();
            upFile.f_ftype_id = Int32.Parse(this.DropDownList1.Text);
            //可被共享
            upFile.f_isshare=1;
            //部门ID
            upFile.f_dept_id = u.u_dept_id;
            //接收人ID
            upFile.f_takeu_id = u.u_id;
            upFile.f_sendu_id = u.u_id ;

            filesBLL.Insert(upFile);
            Session.Add("upfile",upFile);
            this.Response.Redirect("upsecce.aspx");
            
            
        }
    }
    
}
